"""
:提供数据接口
"""

import json


class StuData:
    def __init__(self):
        self.stu_sign_in_count_of_2019 = 0  # 最近一日学生打卡人数，初始化为0
        self.stu_sign_in_count_of_2018 = 0  # 最近一日学生打卡人数，初始化为0
        self.stu_sign_in_count_of_2017 = 0  # 最近一日学生打卡人数，初始化为0
        self.history_sign_of_2019 = {}  # 2019级打卡历史
        self.history_sign_of_2018 = {}  # 2018级打卡历史
        self.history_sign_of_2017 = {}  # 2017级打卡历史
        self.sign_in_after_twenty = {}  # 20点后打卡年级
        self.history_sign = {}  # 打卡人数历史
        self.location = {}  # 位置

    def load_data(self):
        # 从数据文件加载数据
        with open('data/stu_data/stu_data.json', 'r') as f:
            data = json.load(f)
            self.stu_sign_in_count_of_2019 = data['2019']
            self.stu_sign_in_count_of_2018 = data['2018']
            self.stu_sign_in_count_of_2017 = data['2017']
        with open('data/stu_data/stu_2017.json', 'r') as f:
            self.history_sign_of_2017 = json.load(f)
        with open('data/stu_data/stu_2018.json', 'r') as f:
            self.history_sign_of_2018 = json.load(f)
        with open('data/stu_data/stu_2019.json', 'r') as f:
            self.history_sign_of_2019 = json.load(f)

        with open('data/stu_data/stu_after_twenty.json', 'r') as f:
            self.sign_in_after_twenty = json.load(f)
        with open('data/stu_data/stu_all_history.json', 'r') as f:
            self.history_sign = json.load(f)
        with open('data/stu_data/stu_location.json', 'r') as f:
            self.location = json.load(f)


if __name__ == '__main__':
    sy = StuData()
    sy.load_data()
